import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 设备台账信息 */
export interface EquipmentManage {
  id: string // 设备编码
  equipmentName?: string // 设备名称
  deptId: number // 所属部门
  equipmentClassify: number // 设备分类
  equipmentStatus: number // 设备状态
  equipmentType: number // 设备类型
  equipmentModel: string // 规格型号
  equipmentPower: number // 设备功率kw
  equipmentWeight: number // 设备重量
  equipmentTonnage: number // 设备吨位
  installPosition: string // 安装位置
  installDate: string | Dayjs // 安装日期
  productionDate: string | Dayjs // 投产日期
  unit: string // 单位
  equipmentProducer: string // 设备厂家
  contacts: string // 联系人
  contactsNumber: string // 联系电话
  useType: number // 使用状态
  maintainDatetime: string | Dayjs // 最近一次保养时间
  remark: string // 备注
}

// 设备台账 API
export const EquipmentManageApi = {
  // 查询设备台账分页
  getEquipmentManagePage: async (params: any) => {
    return await request.get({ url: `/business/equipment-manage/page`, params })
  },

  // 查询设备台账分页
  getEquipmentManagePageDamage: async (params: any) => {
    return await request.get({ url: `/Damage/equipment-keep-config/damagePageEquipment`, params })
  },

  // 查询设备台账分页
  getEquipmentManageCheckPage: async (params: any) => {
    return await request.get({ url: `/business/equipment-manage/checkPage`, params })
  },

  // 查询所有设备
  getEquipmentManageList: async (params) => {
    return await request.get({ url: `/business/equipment-manage/list`, params })
  },

  // 查询设备台账详情
  getEquipmentManage: async (id: number) => {
    return await request.get({ url: `/business/equipment-manage/get?id=` + id })
  },

  // 新增设备台账
  createEquipmentManage: async (data: EquipmentManage) => {
    return await request.post({ url: `/business/equipment-manage/create`, data })
  },

  // 修改设备台账
  updateEquipmentManage: async (data: EquipmentManage) => {
    return await request.put({ url: `/business/equipment-manage/update`, data })
  },

  // 删除设备台账
  deleteEquipmentManage: async (id: number) => {
    return await request.delete({ url: `/business/equipment-manage/delete?id=` + id })
  },

  /** 批量删除设备台账 */
  deleteEquipmentManageList: async (ids: number[]) => {
    return await request.delete({
      url: `/business/equipment-manage/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出设备台账 Excel
  exportEquipmentManage: async (params) => {
    return await request.download({ url: `/business/equipment-manage/export-excel`, params })
  },

  // 下载设备导入模板
  importEqupmentTemplate: async () => {
    return request.download({ url: '/business/equipment-manage/get-import-template' })
  }
}
